package com.zrrd.bufferedStream;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

/**
 * @author WanJl
 * @version 1.0
 * @title BufferedWriterDemo01
 * @description 字符缓冲输出流
 * @create 2024/5/26
 */
public class BufferedWriterDemo01 {
    public static void main(String[] args) {
        FileWriter fw = null;
        BufferedWriter bw = null;

        try {
            fw=new FileWriter("E:/users/abc.txt",true);
            bw = new BufferedWriter(fw);

            for (int i = 0; i < 10; i++) {
                bw.write("hello,张"+i);
                bw.newLine();//换行
                bw.flush();//刷新
            }

        } catch (IOException e) {
            throw new RuntimeException(e);
        }finally {
            try {
                bw.close();
                fw.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

    }
}
